/*
 * @Author: cl
 * @Description:
 * @Date: 2023-04-18 11:12:58
 * @LastEditTime: 2023-05-04 17:48:18
 * @FilePath: \jsnode\nestjs\naota\src\student\student.controller.ts
 * @LastEditors: cl
 */
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'
import { ApiTags } from '@nestjs/swagger'
import { CreateStudentDto } from './dto/create-student.dto'
import { UpdateStudentDto } from './dto/update-student.dto'
import { StuInfo } from './entities/stuInfo.entity'
import { Student } from './entities/student.entity'
import { StudentService } from './student.service'
import { Auth } from 'src/user/strategy/auth.decorator'

@Controller('student')
@ApiTags('学生')
export class StudentController {
  constructor(private readonly studentService: StudentService) {}

  @Post('/add')
  create(@Body() createStudentDto: CreateStudentDto) {
    return this.studentService.create(createStudentDto)
  }
  @Post('/addUserInfo')
  addUserInfo(@Body() student: Student) {
    console.log(student)
    return this.studentService.addUserInfo(student)
  }

  @Get('/findAll')
  @Auth()
  findAll(@Query('keyWord') keyWord: string) {
    console.log(keyWord)
    return this.studentService.findAll(keyWord)
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.studentService.findOne(+id)
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateStudentDto: UpdateStudentDto) {
    return this.studentService.update(+id, updateStudentDto)
  }
  @Patch('/updateUserInfo/:id')
  updateUserInfo(@Param('id') id: string, @Body() stuInfo: StuInfo) {
    return this.studentService.updateUserInfo(+id, stuInfo)
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.studentService.remove(+id)
  }
}
